<template>
  <div>
    <div style="display:flex;justify-content: center;">
      <div>
        <h1 style="letter-spacing:0.1em;text-align: center">{{ assessname }}</h1>
        <el-row>
          <el-col class="basicCondition" style="width: 1000px;">
            <el-row>
              <el-col>
                <div>
                  <h3 class="h2Bold">一、基本情况</h3>
                </div>
              </el-col>
            </el-row>
            <el-row type="flex" justify="space-between">
              <el-col :span="6">姓名: {{ pat.patientName }}</el-col>
              <el-col :span="6">性别: {{ gender }}</el-col>
              <el-col :span="6">年龄: {{ pat.patientAge }}</el-col>
              <el-col :span="6">科室: {{ pdepartment }}</el-col>
            </el-row>
            <el-row>患者编号：{{ `000${pat.patientNo}` }}</el-row>
            <el-row style="letter-spacing:0.1em;line-height: 1.5em;">病情摘要：{{ pat.illnessSummary }}</el-row>
            <el-row style="letter-spacing:0.1em;line-height: 1.5em;">既往史：{{ pat.preHistory }}</el-row>
            <el-row style="letter-spacing:0.1em;line-height: 1.5em;">诊断：{{ pat.preDiagnose }}</el-row>
            <el-row>
              <el-col :span="6">
                评定日期：{{ createtime.slice(0,10) }}
              </el-col>
              <el-col :span="6">
                评定人：{{ doctorname }}
              </el-col>
            </el-row>
          </el-col>
        </el-row>
        <div v-for="(item,index) in comList">
          <el-row type="flex" align="middle" style="margin-top: 10px">
            <el-col>
              <div class="grid-content">
                <h3 class="h2Bold">{{ item.titleName }}</h3>
              </div>
            </el-col>
          </el-row>
          <div class="containerClass">
            <el-row v-for="(assname,index) in item.assConfig" :key="index" :assname="assname">
              <el-col :span="22" :offset="1">
                <keep-alive>
                  <component
                    :is="assname"
                    :istrans="true"
                    :fromdata="fromdata[assname]"
                  ></component>
                </keep-alive>
              </el-col>
            </el-row>
          </div>
        </div>
      </div>
    </div>
    <el-row>
      <div v-show="status<3" style="margin:60px 400px 80px 300px;">
        <el-alert
          title="当前状态：未审核"
          type="warning"
          center
          :closable="false"
          description="title"
          show-icon>''
        </el-alert>
      </div>
      <div v-show="status==5" style="margin: 60px 400px 80px 300px;">
        <el-alert
          title="当前状态：审核未通过"
          type="info"
          center
          :closable="false"
          description=""
          show-icon>审核意见：{{auditOpinion}}
        </el-alert>
      </div>
      <div v-show="status==3" style="margin:60px 400px 80px 300px;">
        <el-alert
          title="当前状态：审核已通过"
          type="success"
          center
          :closable="false"
          description="title"
          show-icon>''
        </el-alert>
      </div>
    </el-row>
    <el-footer style="display: flex;justify-content: center;" >
      <el-button style="height:50px " type="primary" @click="fanhui">返 回</el-button>
    </el-footer>
  </div>
</template>

<script>
import {getAssess} from "@/api/gaoxin/assess";

export default {
  name: "data_show",
  created() {
    this.assessname = this.$route.params.assdata.assessName;
    this.doctorname = this.$route.params.assdata.doctorName;
    this.createtime = this.$route.params.assdata.data.createTime;
    this.assessId = this.$route.params.assdata.assessId;
    this.fromdata = this.$route.params.assdata.data;
    this.auditOpinion=this.fromdata.auditOpinion;
    this.status=this.fromdata.status
    this.pat=this.$route.params.pat;
    console.log(this.pat)
    // this.fromdata=JSON.parse(this.fromdata);
    this.quzhuanyi();
    this.getass();
    // setTimeout(() => {
    //   this.pgFormValue();
    // },1000);

  },
  data() {
    return {
      fromdata: {},
      assessname: "",
      assessId: "",
      doctorname: '',
      createtime: '',
      assdata: {},
      assess: {},
      comList: [],
      pgForm: "",
      pat:{},
      auditOpinion:"",
      status:"",
    }
  },
  methods: {
    fanhui(){
      // this.$router.go(-1);
      // console.log(this.pat)
      // this.$tab.closeOpenPage({name:'patient_detail',params:{pat:this.pat}})
      this.$tab.closeOpenPage();
      this.$router.go(-1);
      // this.$tab.closeOpenPage({path:'/gaoxin/patient/detail/'});
    },
    quzhuanyi() {
      var temp = this.fromdata.assessData;
      // console.log(String.toString(temp))
      var reg=/\\/g;
      let replaceAfter = temp.toString().replace(reg,'');
      console.log('old this.fromdata:',this.fromdata)
      this.fromdata=JSON.parse(replaceAfter);
      console.log('new this.fromdata:',this.fromdata)
    },
    getass() {
      getAssess(this.assessId).then(res => {
        this.assess = res.data;
        this.comList = JSON.parse(this.assess.assessConfig);
        console.log('this.comList',this.comList)
      })
    },
    // pgFormValue() {
    //   let k = 0;
    //   for (let i = 0; i < this.comList.length; i++) {
    //     this.comList[i].assConfig.forEach(item => {
    //       let assname = item;
    //       this.$refs.com[k++].pgForm = this.fromdata[assname];
    //     });
    //   }
    // }
  },
  computed: {
    pdepartment(){
      if(this.pat.department === '0') return '手外科'
      if(this.pat.department === '1') return '骨科'
    },
    gender(){
      if(this.pat.patientGender === '0') return '男'
      if(this.pat.patientGender === '1') return '女'
      if(this.pat.patientGender === '2') return '未知'
    },
  }
}
</script>

<style>
.basicCondition .el-row{
  margin-bottom: 20px;
}
.h2Bold {
  font-weight: 600;
}
</style>
